/*
Copyright (C) 2015 Marien Raat

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <progressWindow.h>

ProgressWindow::ProgressWindow(sf::Font *textFont)
{
    windowText.setFont(*textFont);

    float padding = 8.0f;
    sf::Vector2f windowSize(600, 200);
    popupWindow.setSize(windowSize);
    popupWindow.setPosition((sf::Vector2f(1224, 1024)
                             - windowSize) / 2.0f);
    popupWindow.setFillColor(sf::Color(160, 160, 160));
    popupWindow.setOutlineColor(sf::Color::Black);
    popupWindow.setOutlineThickness(4.0f);

    windowText.setPosition(popupWindow.getPosition()
                           + sf::Vector2f(padding, padding));
    windowText.setColor(sf::Color::Black);
    windowText.setCharacterSize(30);

    barBase.setPosition(popupWindow.getPosition()
                        + sf::Vector2f(padding, 100));
    barBase.setSize(sf::Vector2f(600.0f - 2 * padding,
                                 50.0f));
    barBase.setFillColor(sf::Color(100, 100, 100));

    barDone.setPosition(barBase.getPosition()
                        + sf::Vector2f(2, 2));
    barDone.setFillColor(sf::Color::Green);
}

void ProgressWindow::draw(sf::RenderWindow *window, float peruntage,
                          std::string string)
{
    windowText.setString(string);
    barDone.setSize(sf::Vector2f(peruntage *
                                 (barBase.getSize().x - 4),
                                 barBase.getSize().y - 4));


    window->draw(popupWindow);
    window->draw(windowText);
    window->draw(barBase);
    window->draw(barDone);
}
